package com.ims.core.doc.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ims.common.annotation.Log;
import com.ims.common.core.controller.BaseController;
import com.ims.common.core.domain.AjaxResult;
import com.ims.common.enums.BusinessType;
import com.ims.core.doc.domain.TInNon1005;
import com.ims.core.doc.service.ITInNon1005Service;
import com.ims.common.utils.poi.ExcelUtil;
import com.ims.common.core.page.TableDataInfo;

/**
 * 通用定额发票Controller
 *
 * @author IMS
 * @date 2024-11-20
 */
@RestController
@RequestMapping("/doc/tongyong")
public class TInNon1005Controller extends BaseController
{
    @Autowired
    private ITInNon1005Service tInNon1005Service;

    /**
     * 查询通用定额发票列表
     */
    @PreAuthorize("@ss.hasPermi('doc:tongyong:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInNon1005 tInNon1005)
    {
        startPage();
        List<TInNon1005> list = tInNon1005Service.selectTInNon1005List(tInNon1005);
        return getDataTable(list);
    }

    /**
     * 导出通用定额发票列表
     */
    @PreAuthorize("@ss.hasPermi('doc:tongyong:export')")
    @Log(title = "通用定额发票", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TInNon1005 tInNon1005)
    {
        List<TInNon1005> list = tInNon1005Service.selectTInNon1005List(tInNon1005);
        ExcelUtil<TInNon1005> util = new ExcelUtil<TInNon1005>(TInNon1005.class);
        util.exportExcel(response, list, "通用定额发票数据");
    }

    /**
     * 获取通用定额发票详细信息
     */
    @PreAuthorize("@ss.hasPermi('doc:tongyong:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tInNon1005Service.selectTInNon1005ById(id));
    }

    /**
     * 新增通用定额发票
     */
    @PreAuthorize("@ss.hasPermi('doc:tongyong:add')")
    @Log(title = "通用定额发票", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TInNon1005 tInNon1005)
    {
        return toAjax(tInNon1005Service.insertTInNon1005(tInNon1005));
    }

    /**
     * 修改通用定额发票
     */
    @PreAuthorize("@ss.hasPermi('doc:tongyong:edit')")
    @Log(title = "通用定额发票", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInNon1005 tInNon1005)
    {
        return toAjax(tInNon1005Service.updateTInNon1005(tInNon1005));
    }

    /**
     * 删除通用定额发票
     */
    @PreAuthorize("@ss.hasPermi('doc:tongyong:remove')")
    @Log(title = "通用定额发票", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tInNon1005Service.deleteTInNon1005ByIds(ids));
    }
}
